<template>
  <el-form ref="searchForm" :model="searchForm" label-width="120px">
    <el-row v-if="conditionCount > 0">
      <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6"><el-form-item label="父菜单名称" prop="parentMetaTitle" label-for="parentMetaTitle">
	<el-input v-model="searchForm.parentMetaTitle" element-id="parentMetaTitle" placeholder="请输入父菜单名称" clearable @keyup.enter.native="handleSubmit"/>
</el-form-item>
</el-col><el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6"><el-form-item label="英文名称" prop="name" label-for="name">
	<el-input v-model="searchForm.name" element-id="name" placeholder="请输入英文名称" clearable @keyup.enter.native="handleSubmit"/>
</el-form-item>
</el-col><el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6"><el-form-item label="中文名称" prop="metaTitle" label-for="metaTitle">
	<el-input v-model="searchForm.metaTitle" element-id="metaTitle" placeholder="请输入中文名称" clearable @keyup.enter.native="handleSubmit"/>
</el-form-item>
</el-col>
      <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
        <el-button type="primary" style="margin-left: 10px;" :loading="loading.search" @click="handleSubmit">搜索</el-button>
        <el-button @click="handleReset">重置</el-button>
        <a v-if="conditionCount > 3" style="margin-left: 10px;" @click="collapse = !collapse">
          <el-button type="text" v-if="!collapse">
            展开
            <svg-icon icon-class="ios-arrow-down" />
          </el-button>
          <el-button v-else type="text">
            收起
            <svg-icon icon-class="ios-arrow-up" />
          </el-button>
        </a>
      </el-col>
    </el-row>
    <el-row v-if="collapse">
      <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
        <el-form-item label="菜单等级" prop="menuLevel">
              <el-select
                v-model="searchForm.menuLevel"
                placeholder="请选择菜单等级"
                clearable
                style="width: 100%;"
                @change="handleSubmit"
              >
                <el-option
                  v-for="item in selects.menuLevelSelect"
                  :value="item.value"
                  :key="item.value"
                  :label="item.displayValue"
                ></el-option>
              </el-select>
  </el-form-item>
</el-col>
    </el-row>
  </el-form>
</template>
<script>
import * as utils from '@/utils/utils'
import * as ResponseStatus from '@/utils/response-status'
export default {
  name: 'SysMenuSearchQuick',
  data() {
    return {
      loading: {
        search: false
      },
      conditionCount: 4,
      collapse: false,
      searchForm: {
        pageNo: 1,
        pageSize: 10,
        sortColumn: undefined,
        sortOrder: undefined,
        id: undefined,
idMin: undefined, 
idMax: undefined, 
parentId: undefined,
parentIdMin: undefined, 
parentIdMax: undefined, 
parentMetaTitle: undefined,
parentIsActive: undefined,
parentIsActiveMin: undefined, 
parentIsActiveMax: undefined, 
path: undefined,
name: undefined,
metaTitle: undefined,
redirect: undefined,
component: undefined,
hidden: undefined,
hiddenMin: undefined, 
hiddenMax: undefined, 
alwaysShow: undefined,
alwaysShowMin: undefined, 
alwaysShowMax: undefined, 
metaIcon: undefined,
metaRoles: undefined,
metaBreadcrumb: undefined,
metaBreadcrumbMin: undefined, 
metaBreadcrumbMax: undefined, 
metaAffix: undefined,
metaAffixMin: undefined, 
metaAffixMax: undefined, 
metaNoCache: undefined,
metaNoCacheMin: undefined, 
metaNoCacheMax: undefined, 
menuLevel: undefined,
menuLevelMin: undefined, 
menuLevelMax: undefined, 
menuOrder: undefined,
menuOrderMin: undefined, 
menuOrderMax: undefined, 
description: undefined,
version: undefined,
versionMin: undefined, 
versionMax: undefined, 
createTime: undefined,
createTimeMin: undefined, 
createTimeMax: undefined, 
updateTime: undefined,
updateTimeMin: undefined, 
updateTimeMax: undefined, 
isActive: undefined,
isActiveMin: undefined, 
isActiveMax: undefined, 

      },
      dataDictCodes: ['YES_NO', 'SYS_MENU_LEVEL'],
      selects: {
        parentIsActiveSelect: [],
hiddenSelect: [],
alwaysShowSelect: [],
metaBreadcrumbSelect: [],
metaAffixSelect: [],
metaNoCacheSelect: [],
menuLevelSelect: [],
isActiveSelect: [],

      }
    }
  },
  computed: {},
  mounted() {
    this.initDataDict()
  },
  methods: {
    initDataDict() {
    utils
      .getDataDict(this.dataDictCodes)
      .then(response => {
        if (response) {
          utils.getSelectDictItems({
            mainComponent: this,
            dataDictItems: response,
            dictCode: 'YES_NO',
            formProp: 'parentIsActive',
            dataProp: 'parentIsActiveSelect'
          })
utils.getSelectDictItems({
            mainComponent: this,
            dataDictItems: response,
            dictCode: 'YES_NO',
            formProp: 'hidden',
            dataProp: 'hiddenSelect'
          })
utils.getSelectDictItems({
            mainComponent: this,
            dataDictItems: response,
            dictCode: 'YES_NO',
            formProp: 'alwaysShow',
            dataProp: 'alwaysShowSelect'
          })
utils.getSelectDictItems({
            mainComponent: this,
            dataDictItems: response,
            dictCode: 'YES_NO',
            formProp: 'metaBreadcrumb',
            dataProp: 'metaBreadcrumbSelect'
          })
utils.getSelectDictItems({
            mainComponent: this,
            dataDictItems: response,
            dictCode: 'YES_NO',
            formProp: 'metaAffix',
            dataProp: 'metaAffixSelect'
          })
utils.getSelectDictItems({
            mainComponent: this,
            dataDictItems: response,
            dictCode: 'YES_NO',
            formProp: 'metaNoCache',
            dataProp: 'metaNoCacheSelect'
          })
utils.getSelectDictItems({
            mainComponent: this,
            dataDictItems: response,
            dictCode: 'SYS_MENU_LEVEL',
            formProp: 'menuLevel',
            dataProp: 'menuLevelSelect'
          })
utils.getSelectDictItems({
            mainComponent: this,
            dataDictItems: response,
            dictCode: 'YES_NO',
            formProp: 'isActive',
            dataProp: 'isActiveSelect'
          })

        }
      })
      .catch(error => {
        console.log(error)
      })
    },
    resetForm(excludeProps) {
      for (let key in this.searchForm) {
        if (excludeProps && excludeProps.includes(key)) {
          continue
        }
        this.searchForm[key] = undefined
      }
    },
    handleSubmit() {
      this.$emit('quickSearch')
    },
    handleReset() {
      this.$emit('researchTable')
    }
  }
}
</script>
<style>
.ivu-quick-opt {
  text-align: right;
}
</style>